package com.iwhalecloud.bss.kite.cucc.web.service.accept.handler.attr;


import com.iwhalecloud.bss.kite.client.dto.cust.ContextCustDTO;
import com.iwhalecloud.bss.kite.client.vo.scene.CommonAttrVO;
import com.iwhalecloud.bss.kite.common.util.KiteBeanUtils;
import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.cucc.client.dto.cust.CuccContextCustDTO;
import com.iwhalecloud.bss.kite.manager.api.IQuerySceneInstService;
import com.iwhalecloud.bss.kite.manager.inst.KiteSceneInst;
import com.iwhalecloud.bss.kite.web.context.KiteWebContext;
import com.iwhalecloud.bss.kite.web.service.accept.attr.handler.AbstractAttrHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author kangchuang
 * 大数据商机属性处理类
 * @date 2021/04/29
 */
@Service
public class OpportunityAttrHandler extends AbstractAttrHandler {
    @Autowired
    IQuerySceneInstService querySceneInstService;
    @Override
    public void init(CommonAttrVO commonAttrVO) {
        ContextCustDTO custDTO1 = KiteWebContext.getContext().getCust();
        KiteSceneInst sceneInst = querySceneInstService.getSceneInst(KiteWebContext.getContext().getCurrentSceneInstId());
        if("1068".equals(sceneInst.getServiceOfferId())){
            CuccContextCustDTO custDTO = KiteBeanUtils.transform(custDTO1, CuccContextCustDTO.class);
            if ("USR0001".equals(commonAttrVO.getFieldName())&&KiteStringUtils.isNotEmpty(custDTO.getOppoNum())) {
                commonAttrVO.setValue(custDTO.getOppoNum());
                commonAttrVO.setValueDesc(custDTO.getOppoNum());
                setCommonAttr(commonAttrVO);
            }

            if ("USR0002".equals(commonAttrVO.getFieldName())&&KiteStringUtils.isNotEmpty(custDTO.getOppoName())) {
                commonAttrVO.setValue(custDTO.getOppoName());
                commonAttrVO.setValueDesc(custDTO.getOppoName());
                setCommonAttr(commonAttrVO);
            }
        }

    }
}
